﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MediPlatform.Domain.Order
{
    /// <summary>
    /// 药品订单主表
    /// </summary>
    public class MedicalOrder
    {
        /// <summary>
        /// 主键，自增
        /// </summary>
        [Key]
        public long? Id { get; set; }

        /// <summary>
        /// 唯一订单编号
        /// </summary>
        [StringLength(64)]
        public string? OrderNo { get; set; }

        /// <summary>
        /// 下单用户ID，外键关联用户表
        /// </summary>
        public long? UserId { get; set; }

        /// <summary>
        /// 用户导航属性
        /// </summary>
        public virtual User? User { get; set; }

        /// <summary>
        /// 订单总金额
        /// </summary>
        [Range(0, double.MaxValue)]
        public decimal? TotalAmount { get; set; }

        /// <summary>
        /// 实际支付金额（可能含优惠）
        /// </summary>
        [Range(0, double.MaxValue)]
        public decimal? ActualAmount { get; set; }

        /// <summary>
        /// 订单状态：0-待发货, 1-待收货, 2-已收货
        /// </summary>
        public int? Status { get; set; }

        /// <summary>
        /// 支付方式：wechat, alipay, bank_card
        /// </summary>
        [StringLength(20)]
        public string? PaymentMethod { get; set; }

        /// <summary>
        /// 支付完成时间
        /// </summary>
        public DateTime? PaymentTime { get; set; }

        /// <summary>
        /// 取消订单原因
        /// </summary>
        public string? CancelReason { get; set; }

        /// <summary>
        /// 退款金额
        /// </summary>
        public decimal? RefundAmount { get; set; }

        /// <summary>
        /// 退款完成时间
        /// </summary>
        public DateTime? RefundTime { get; set; }

        /// <summary>
        /// 退款状态：0-无退款, 1-申请中, 2-已同意, 3-已拒绝
        /// </summary>
        public int? RefundStatus { get; set; }

        /// <summary>
        /// 配送地址（JSON格式存储详细信息）
        /// </summary>
        public string? DeliveryAddress { get; set; }

        /// <summary>
        /// 物流公司名称
        /// </summary>
        [StringLength(50)]
        public string? LogisticsCompany { get; set; }

        /// <summary>
        /// 物流单号
        /// </summary>
        [StringLength(50)]
        public string? TrackingNumber { get; set; }

        /// <summary>
        /// 签收时间
        /// </summary>
        public DateTime? SignTime { get; set; }

        /// <summary>
        /// 扩展信息，如优惠券ID、发票信息等
        /// </summary>
        public string? ExtraInfo { get; set; }

        /// <summary>
        /// 创建时间
        /// </summary>
        public DateTime? CreatedAt { get; set; } = DateTime.Now;

        /// <summary>
        /// 更新时间
        /// </summary>
        public DateTime? UpdatedAt { get; set; } = DateTime.Now;

    }
}
